#include "SpriteFX.h"

SpriteFX::SpriteFX(ID3D11Device* device)
	: AbstractFX(device, L"FX/Sprite.fxo") 
{
	//Init pointers.
	texture = NULL;

	//Call init functions
	InitInputLayout(device);
	InitShaderVariablePointers();
}

SpriteFX::~SpriteFX()
{}

void SpriteFX::InitInputLayout(ID3D11Device* device)
{
	//Fillout input layout description.
	const D3D11_INPUT_ELEMENT_DESC ipLayout[] = 
	{
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD",  0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
		{"COLOUR",   0, DXGI_FORMAT_B8G8R8A8_UNORM, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0}
	};

	//Create our input layout 	
	CreateInputLayout(device, ipLayout, 3);
}

void SpriteFX::InitShaderVariablePointers()
{
	texture = effect->GetVariableByName("SpriteTex")->AsShaderResource();
}

void SpriteFX::SetTexture(ID3D11ShaderResourceView* tex)
{
	texture->SetResource(tex);
}